<%@page import="java.io.Console"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>夕阳红老汉信息有限公司</title>
<link rel="shortcut icon" href="images/xi.ico" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/modalDetail.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/layui/css/layui.css"
	media="all">
<!--2. Custom styles for this template -->
<!-- ${pageContext.request.contextPath}/ 得到上下文的路径值 -->
<%-- <link href="${pageContext.request.contextPath}/css/dashboard.css" rel="stylesheet"> --%>
</head>
<body>
	<!-- Jumbotron -->
	<header class="jumbotron">
		<p class="lead">用自动化构建工具增强你的工作流程！</p>
		<p>
			<a class="btn btn-lg btn-default btn-getting-started"
				href="javascript:;" role="button">开始使用</a>
		</p>
	</header>
	<div class="title-wrap">
		<div class="logo"></div>
		<div class="return">
			<a href="index.jsp">返回主页</a>
		</div>
		<div class="return">
			<a href="">查看简历</a>
		</div>

	</div>
	<form action="ZhiweiServlet" method="get">
		<div class="content">
			<div class="page_1">
				<h2>
					已选择的模板--<span id="chooseModal"></span>--<span id="times"></span>
				</h2>
			</div>
			<div class="page_2">
				<div class="row">
					<div class="col-md-6">
						<h2>岗位类别</h2>
						<div class="input-group input-group-md">
							<span class="input-group-addon" id="sizing-addon1">*</span> <select
								class="form-control" id="bumen" name="bumen">
								<option value="运营部">运营部</option>
								<option value="后勤部">后勤部</option>
								<option value="技术部">技术部</option>
								<option value="管理部">管理部</option>

							</select>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-6">
						<h2>岗位名称</h2>
						<div class="input-group input-group-md">
							<span class="input-group-addon" id="sizing-addon2">*</span> <input
								type="text" class="form-control" placeholder="岗位名称"
								aria-describedby="sizing-addon2" id="name" name="name" />
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-6">
						<h2>工作地点</h2>
						<div class="input-group input-group-md">
							<span class="input-group-addon" id="sizing-addon3">*</span> <select
								class="form-control" id="didian" name="didian">
								<option value="上海">上海</option>
								<option value="广东">广东</option>
								<option value="北京">北京</option>
								<option value="天津">天津</option>
								<option value="重庆">重庆</option>
								<option value="成都">成都</option>
								<option value="厦门">厦门</option>
							</select>
						</div>
					</div>
					<div class="col-md-6">
						<h2>薪资待遇</h2>
						<div class="input-group input-group-md">
							<span class="input-group-addon">*</span> <input type="text"
								class="form-control" placeholder="薪资待遇"
								aria-describedby="sizing-addon2" id="salary" name="salary" />
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-6" id="need">
						<h2>岗位需求</h2>
						<div class="row input-group input-group-md needrow">
							<span class="input-group-addon">*</span> <input type="text"
								class="form-control" placeholder="岗位需求"
								aria-describedby="sizing-addon4" id="xuqiu" name="xuqiu" />

						</div>
					</div>
					<div class="col-md-6" id="work">
						<h2>工作内容</h2>
						<div class="input-group input-group-md workrow">
							<span class="input-group-addon">*</span> <input type="text"
								class="form-control" placeholder="工作内容"
								aria-describedby="sizing-addon5" id="neirong" name="neirong" />
						</div>
					</div>
				</div>
				<div class="row" style="margin-top: 20px;">
					<input type="hidden" name="op" value="add">
					<%
						//重复提交 I. 在session范围内产生一个token的值.。
						session.setAttribute("token", System.nanoTime() + "");
					%>
					<!-- 重复提交 II 将token通过隐藏域传递给servlet -->
					<input type="hidden" name="token" value="${sessionScope.token}">
					<div class="col-md-12">
						<button type="submit" class="btn" id="login-btn"
							style="float: right;">确认添加</button>
					</div>
				</div>
			</div>
	</form>
	<div class="page_3">
		<div class="panel panel-default">
			<div class="panel-heading"
				style="background-color: #4e372f; color: white;">
				<h4 class="panel-title">
					<a data-toggle="collapse" data-parent="#accordion"
						href="#collapseOne"> 已添加的招聘信息 </a>
				</h4>
			</div>
			<div id="collapseOne" class="panel-collapse collapse in">
				<div class="panel-body">
					<table class="table table-striped table-hover table-condensed">
						<thead>
							<tr>
								<th>序号</th>
								<th>岗位类别</th>
								<th>岗位名称</th>
								<th>工作地点</th>
								<th>岗位需求</th>
								<th>工作内容</th>
								<th>薪资待遇</th>
								<th>操作</th>

							</tr>
						</thead>
						<tbody>
							<c:if test="${pd==null}">

								<c:redirect url="ZhiweiServlet?op=queryByPage"></c:redirect>
							</c:if>
							<c:if test="${pd!=null}">
								<c:forEach items="${pd.data}" var="zhiwei">
									<tr>
										<td>${zhiwei.gid}</td>
										<td>${zhiwei.bumen}</td>
										<td>${zhiwei.name}</td>
										<td>${zhiwei.didian}</td>
										<td>${zhiwei.xuqiu}</td>
										<td>${zhiwei.neirong}</td>
										<td>${zhiwei.salary}</td>
										<td><a class="deljianli" href="#">删除</a>|<a
											class="updateType" href="#">修改</a></td>
									</tr>
								</c:forEach>
							</c:if>

						</tbody>
					</table>
				</div>
				<div id="pagediv" style="text-align: center"3></div>

			</div>

		</div>
	</div>
	</div>
	</div>
	</div>
	</div>
	</div>
	</div>
	<footer>
		<div style="text-align: center">
			<a href="http://www.readboy.com/list-58-1.html">版权声明</a>©2017
			读书郎教育科技有限公司 版权所有(<a href="http://www.miibeian.gov.cn/">粤ICP备12092216号-1</a>)<br>
			<a href="http://wljg.gdgs.gov.cn/corpsrch.aspx?key=442000000171401"
				target="_blank"
				title="企业名称：读书郎教育科技有限公司&nbsp;&nbsp;法定代表人：秦曙光&nbsp;&nbsp;标识状态：已激活&nbsp;&nbsp;"
				style="line-height: 35px"> <img
				src="http://www.readboy.com/statics/images/gs_icon_201411260029331.png"
				alt="" style="display: inline-block; position: static;">粤工商备P201708002261
			</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a target="_blank"
				href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=44200002442753"
				style="line-height: 35px"><img
				src="http://www.readboy.com/statics/images/gaba.png"
				style="display: inline-block; position: static;" />粤公网安备
				44200002442753号</a>
		</div>
	</footer>
	<script src="layui/layui.js" charset="utf-8"></script>
	<script src="${pageContext.request.contextPath}/js/jquery-2.0.3.js"></script>
	<script>
    layui.use(['laypage', 'layer'], function(){
    	  var laypage = layui.laypage
    	  ,layer = layui.layer;
    	  laypage.render({
    		    elem: 'pagediv' // 分页的导航在哪里显示，pagediv是层id
    		    ,theme: '#428bca'  //颜色
    		    ,count: ${pd.totalCount} //总记录数
    		    ,curr: ${pd.page}  //当前页
    		    ,limit: ${pd.pageSize}//当前页显示的记录数
    		    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
    		    ,jump: function(obj, first){ //跳转页面时候的动作
    			    //obj包含了当前分页的所有参数，比如：
    			    // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
    			   // console.log(obj.limit); //得到每页显示的条数
    			    
    			    //首次不执行
    			    if(!first){
    			      //do something
    			       location.href="ZhiweiServlet?op=queryByPage&page="+obj.curr+"&pageSize="+obj.limit;
    			    }
    			  }
    		  });
    	  //单击删除事件的开始
     $(".deljianli").click(function(){
    	var gid=$(this).parents("tr").find("td").eq(0).text();
    	layer.confirm('是否确定删除编号为'+ gid+"的职位",{
    		btn:['确定','取消']
    	},function(){
    		 $.ajax({
    			url:"ZhiweiServlet",
    			type:"post",
    			data:{
    				gid:gid,
    				op:"del"
    			},
    			success:function(res){
    				console.log(res);
    				if(res.msg == "true")
	    			{
	    			
	    			layer.msg('删除成功!', {
	    				icon: 1,
	    			    time: 2000, //2s后自动关闭
	    			    btn: ['确定']
	    			  },function(){
	    				  
	    				  //页面刷新
	    				  location.href="ZhiweiServlet?op=queryByPage&page="+${pd.page}+"&pageSize="
	    						  +${pd.pageSize};	    				  
	    			  });	    					    			
	    			}
	    		else{
	    			
	    			layer.msg('删除失败!', {
	    				icon: 1,
	    			    time: 2000, //2s后自动关闭
	    			    btn: ['确定']
	    			  });
	    			
	    		}
	    		
	    	},
	    	dataType: "json"
	    	
	    	
	    	
	    }); 
    	
    		//单机删除事件的结束
	  });
     });
    });
			  
    /***********修改开始******/
    
    $(".updateType").click(function(){
  	  
  	  //得到类型的typeid
  	  var  gid=$(this).parents("tr").find("td").eq(0).text();
  	  var bumen=$(this).parents("tr").find("td").eq(1).text();
  	  var name=$(this).parents("tr").find("td").eq(2).text();
  	  var didian=$(this).parents("tr").find("td").eq(3).text();
  	  var neirong=$(this).parents("tr").find("td").eq(4).text();
  	  var xuqiu=$(this).parents("tr").find("td").eq(5).text();
  	  var salary=$(this).parents("tr").find("td").eq(6).text();
  	  
  	  console.log(gid,bumen,name,didian,neirong,xuqiu,salary);
  	  
  	  $("#ssgid").val(gid);
  	  $("#ssbumen").val(bumen);
  	  $("#ssname").val(name);
  	  $("#ssdidian").val(didian);
  	  $("#ssneirong").val(neirong);
  	  $("#ssxuqiu").val(xuqiu);
  	  $("#sssalary").val(salary);
  	 
  	  
  	
  	//弹出层
  	  layer.open({
  		  type: 1,
  		  area: ['600px', '400px'],
  		  content: $('#updatediv') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
  		});
  	  
  	  
     });
    
    
    
    
    
  
    
    
    /*********修改结束*******/

    
  </script>

	<div id="updatediv" style="display: none; width: 500px">
		<br>
		<form class="layui-form" action="ZhiweiServlet">
           <input type="hidden" name="op" value="updata">
			<div class="layui-form-item">
				<label class="layui-form-label">编号</label>
				<div class="layui-input-block">
					<input type="text" name="ssgid" id="ssgid" required
						lay-verify="required" readonly class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">部门</label>
				<div class="layui-input-block">
					<input type="text" name="ssbumen" id="ssbumen" required
						lay-verify="required" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">名称</label>
				<div class="layui-input-block">
					<input type="text" name="ssname" id="ssname" required
						lay-verify="required" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">地点</label>
				<div class="layui-input-block">
					<input type="text" name="ssdidian" id="ssdidian" required
						lay-verify="required" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">内容</label>
				<div class="layui-input-block">
					<input type="text" name="ssneirong" id="ssneirong" required
						lay-verify="required" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">需求</label>
				<div class="layui-input-block">
					<input type="text" name="ssxuqiu" id="ssxuqiu" required
						lay-verify="required" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">工资</label>
				<div class="layui-input-block">
					<input type="text" name="sssalary" id="sssalary" required
						lay-verify="required" class="layui-input">
				</div>
			</div>





			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</div>
	<script>
  //Demo
  layui.use('form', function(){
    var form = layui.form;
    
    //监听提交
    form.on('submit(formDemo)', function(data){
      
  	  //可以1 表单提交  2 可以用ajax
  	  //得到了表单 中的数据,传递给servlet完成数据访问即可
  	  //未完， 待  "大家" 续
  	  
  	  layer.msg(JSON.stringify(data.field));
      
      //return false是不做表单提交
      //return false;
    });
  });	  
	  
	  
  
    </script>
</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/modalDetail.js"></script>
</html>